function searchMatrix(matrix: number[][], target: number): boolean {
  if (!matrix.length) return false;
  const lines = matrix.length;
  const rows = matrix[0].length;
  let left = 0;
  let right = lines * rows - 1;
  while (right >= left) {
    let mid = Math.ceil((left + right) / 2);
    const v = matrix[Math.floor(mid / rows)][mid % rows];
    if (v === target) return true;
    if (v < target) {
      left = mid + 1;
    } else {
      right = mid - 1;
    }
  }
  return false;
};